package com.zx.webflux.wrapper;


import com.zx.webflux.eunms.WrapperErrEum;
import lombok.*;

import java.io.Serializable;

/**
 * @program: common
 * @description: 响应包装类
 * @author: zhou  xun
 * @create: 2022-09-26 23:52
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
@ToString(callSuper = true)
public class ResponseWrapper implements Serializable {
    /**
     * 错误码
     */
    private Integer code = WrapperErrEum.SUCCESS.getCode();
    /**
     * 消息
     */
    private String msg = WrapperErrEum.SUCCESS.getMsg();

    /**
     * 设置错误消息
     *
     * @param msg 消息
     */
    public void fail(String msg) {
        this.msg = msg;
        this.code = WrapperErrEum.FAIL.getCode();
    }

    /**
     * 判断是否成功
     *
     * @return boolean
     */
    public boolean verifyFail() {
        return WrapperErrEum.FAIL.getCode().equals(code);
    }
}